/*****************************************************************
 MYD Engine v0.1

 File: myd_entity2d.cpp
 Created: 12/06/09
*****************************************************************/
#include "myd_entity2d.h"
#include "graphics/myd_renderer.h"

using namespace myd;

Entity2d::Entity2d ():
					m_kName(""),
					m_fX(0), 
					m_fY(0), 
					m_fW(0),
					m_fH(0),
					m_fRotation(0),
					m_fMovSpeed(0),
					m_fMovAngle(0),
					m_fMovAngleRad(0),
					isMoving(false)
{
}

void Entity2d::draw (Renderer& tm_renderer) const
{
	// set the world matrix
	tm_renderer.setMatrixMode(WORLD);

	// reset the matrix
	tm_renderer.loadIdentity();

	// apply transformation
	tm_renderer.translate(m_fX, m_fY);
	tm_renderer.rotateZ(m_fRotation * 3.14159f / 180.0f);
	tm_renderer.scale(m_fW, m_fH);
}
//----------------------------------------------------------------
void Entity2d::update (float fTimeBetweenFrames)
{
	if (isMoving)
	{
		m_fX += (fTimeBetweenFrames / 1000.0f) * m_fMovSpeed * cos(m_fMovAngleRad);
		m_fY += (fTimeBetweenFrames / 1000.0f) * m_fMovSpeed * sin(m_fMovAngleRad);
	}

}